﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Markup;

namespace Snowdreamist.Windows
{
    public static class XamlResourcesHelper
    {
        public static ResourceDictionary LoadResourceDictionary(Uri xamlUri)
        {
            if (xamlUri == null)
                throw new ArgumentNullException("xamlUri");
            // get resources stream
            var stmResInfo = Application.GetResourceStream(xamlUri);
            if (stmResInfo == null)
                return null;
            using (stmResInfo.Stream)
            {
                var result = XamlReader.Load(stmResInfo.Stream);
                if (result is ResourceDictionary)
                    return (ResourceDictionary)result;
                else
                    return null;
            }
        }
    }
}